footer.init();
var pro_load_page = 2,pro_load_flag = true;
var data = window.sessionStorage.getItem('class_list');
data = JSON.parse(data);
var id = data.id;
var title = '';
if(id == 23){
	header.init("新手入门");
	title = '新手入门';
}else if(id == 24){
	header.init('进阶课堂');
	title = '进阶课堂';
}else if(id == 25){
	header.init('活动中心');
	title = '活动中心';
}else if(id == 26){
	header.init('疑难解答');
	title = '疑难解答';
}
var articleList = {
	init : function(id){
		app.ajax(
			'/Member/News/getting_started_list',
			{
				classid : id
			},function(res){
				if(res.code == 200){
					if(res.list.length > 0){
						app.tpl($('.articles-list'),'tpl-articles-list',res);
								echo.init();
					}else{
						$('.articles-list').html("<div class='tC promp-order' style='position:absolute;top:50%;left:15%;height:30%;width:70%;'><span class='cGrey fS15'>亲  这个页面还没有数据哦~</span></div>");
					}
				}else{
					layer.msg('网络繁忙，请稍候再试');
				}
			}
		);
	},
	loadMore :function(url,data){
		var listLoadingEmpty = '<div style="height:3rem;line-height:3rem;text-align:center;font-size:1.2rem;" class="no-more">努力加载中~<div>';
   		$('.articles-list').append(listLoadingEmpty);
		pro_load_flag = false;
		app.ajax(
			url,
			data,
			function(res){
				$('.articles-list .no-more').remove();
				if(res.code == 200){
						app.tpladd($('.articles-list'),'tpl-articles-list',res);	
								echo.init();
						pro_load_page++;
						pro_load_flag = true;
					//page++;
				}else{						
						var listLoadingEmpty = '<div style="height:3rem;line-height:3rem;text-align:center;font-size:1.2rem;">没有更多数据了~<div>';
						$('.articles-list').append(listLoadingEmpty);
				}
			});	
	}
}

articleList.init(id);
window.onload = function(){
	$('body').on('click','.article-list',function(){//正品综述
		var ids= $(this).attr('data-id');
		app.open('classroom.articleDetail.html','class_article',{id:ids,title:title},window.location.href,document.body.scrollTop);
	});
	
	$(window).scroll(function(){
		echo.init();
		// 当滚动到距底部以上200像素
		var offset = $(".articles-list").offset(),
		dataType = 0,
		data = {};
		var documentHeight = offset.top + $(".articles-list").height();
		if (documentHeight - $(this).scrollTop() - $(this).height()<100){
			var data = window.sessionStorage.getItem('class_list');
			data = JSON.parse(data);
			var id = data.id;
				data = {
					page :pro_load_page,
					limit : 10,
					classid : id
				};
			pro_load_flag && articleList.loadMore('/Member/News/getting_started_list',data);
		}
	});
	
};
